/*
 * @Description: 系统管理-字典管理
 * @Date: 2023-07-18 09:37:48
 * @FilePath: \hksj-vued:\03code\hk-iot\src\api\system\dic\index.ts
 */
import axiosRequest from '/@/utils/request';

/**
 * 字典管理接口接口集合
 * @method addDicType 新增字典类型
 * @method deleteDicType 删除字典类型
 * @method updateDictionary 修改
 * @method queryDicTypeList 查询所有父级字典类型
 */
export function useDicApi() {
  return {
    addDicType: async (params: object) => {
      const res = await axiosRequest({
        url: '/api/dicType/addDicType',
        method: 'post',
        data: params,
      });
      return res;
    },
    deleteDicType: async (params: { 'id': string }) => {
      const res = await axiosRequest({
        url: `/api/dicType/deleteDicType/${params.id}`,
        method: 'delete',
        data: params,
      });
      return res;
    },
    updateDicType: async (params: object) => {
      const res = await axiosRequest({
        url: '/api/dicType/updateDicType',
        method: 'put',
        data: params,
      });
      return res;
    },
    queryDicTypeList: async () => {
      const res = await axiosRequest({
        url: '/api/dicType/queryDicTypeList',
        method: 'post',
        // data: params,
      });
      return res;
    },
    queryDicInfoAllByTypeId: async (params: { 'typeId': string }) => {
      const res = await axiosRequest({
        url: `/api/dicInfo/queryDicInfoAllByTypeId`,
        method: 'post',
        data: params,
        headers: { stringify: true }
      });
      return res;
    },

    // 新增字典子项
    createDictionaryDetail: async (params: object) => {
      const res = await axiosRequest({
        url: '/api/dicInfo/addDicInfo',
        method: 'post',
        data: params,
      });
      return res;
    },
    deleteDictionaryDetail: async (params: { 'id': string }) => {
      const res = await axiosRequest({
        url: `/api/dicInfo/deleteDicInfo/${params.id}`,
        method: 'delete',
        data: params,
      });
      return res;
    },
    updateDictionaryDetail: async (params: object) => {
      const res = await axiosRequest({
        url: '/api/dicInfo/updateDicInfo',
        method: 'put',
        data: params,
      });
      return res;
    },

    // 查询全国省市县区域
    queryAllCityTree: async () => {
      const res = await axiosRequest({
        url: `/api/city/queryAllCityTree`,
        method: 'GET',
      });
      return res;
    },
    // 分配用户所管辖的区域
    assignRegion: async (params: object) => {
      const res = await axiosRequest({
        url: '/api/city/assignRegion',
        method: 'post',
        data: params,
      });
      return res;
    },
    // 查询用户所管辖的区域信息
    queryUserRegion: async (params: { 'id': string }) => {
      const res = await axiosRequest({
        url: `/api/city/queryUserRegion/${params.id}`,
        method: 'get',
        data: params,
      });
      return res;
    },
  };
}
